package com.useeinfo.oa.modules.inspection.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.DateTimeUtils;
import com.useeinfo.oa.modules.maintaining.entity.PeriodInstall;
import com.useeinfo.oa.modules.maintaining.entity.PlannerOrder;

import javax.persistence.*;
import java.util.Date;

/**
 * 计划执行时间
 */
@Entity
@Table(name = "inspection_Execute_Time")
public class InspectionExecuteTime extends SuperClassEntity<InspectionExecuteTime> {

    /**
     * 计划ID
     */
    @ManyToOne
    @JoinColumn(name = "planner_id")
    private PlannerInspection plannerInspection;

    /**
     * 执行时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    private Date executeTime;

    /**
     * 开始时间
     *
     * @return
     */
    private String startTime;

    /**
     * 结束时间
     *
     * @return
     */
    private String endTime;
    /**
     * 运行状态
     */
    private Integer operateStatus=0;//operateStatus作校验，1时才生成工单，0不生成

    /**
     * 周期关键字ID
     *
     * @return
     */
    @ManyToOne
    @JoinColumn(name = "install_id")
    private PeriodInstall periodInstall;
    /**
     * 生成状态(0:未处理,1:已经处理,其他状态为处理失败)
     */
    private Integer status = 0;


    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        jsonObject.put("executeTime", DateTimeUtils.formatDateToString(getExecuteTime()));
        return jsonObject;
    }


    public Date getExecuteTime() {
        return executeTime;
    }

    public void setExecuteTime(Date executeTime) {
        this.executeTime = executeTime;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getOperateStatus() {
        return operateStatus;
    }

    public void setOperateStatus(Integer operateStatus) {
        this.operateStatus = operateStatus;
    }

    public PlannerInspection getPlannerInspection() {
        return plannerInspection;
    }

    public void setPlannerInspection(PlannerInspection plannerInspection) {
        this.plannerInspection = plannerInspection;
    }

    public PeriodInstall getPeriodInstall() {
        return periodInstall;
    }

    public void setPeriodInstall(PeriodInstall periodInstall) {
        this.periodInstall = periodInstall;
    }
}
